/**
 * 
 */
package com.EstateManager.Utils;

import javax.print.attribute.standard.MediaSize.Other;

import net.sf.ehcache.search.parser.MValue.MShort;

/**
 * 创建时间 : 上午9:50:02
 * @author Yonggang Liu
 *
 * FactoryResult.java
 */
public class FactoryResult {
	
	public final static int ERROR = 0;
	public final static int SUCCESS = 1;
	public final static int EXCEPTION = 2;
	public final static int OTHERERROR =10;
	
	
	public static Result getResult(int type, Object data, String message) {
		Result result = new Result();
		switch (type) {
		case ERROR:
			result.setCode(4000);
			result.setMessage(message);
			result.setInfo(message);
			result.setStatus("n");
			result.setData(data);
			break;
		case SUCCESS:
			result.setCode(1000);
			result.setMessage(message);
			result.setData(data);
			result.setStatus("y");
			result.setInfo(message);
			break;
		case EXCEPTION:
			result.setCode(4500);
			result.setData(data);
			result.setInfo(message);
			result.setInfo(message);
			result.setStatus("n");
			break;
		case OTHERERROR:
			result.setCode(6000);
			result.setMessage("其他错误类型");
			result.setInfo("其他错误类型");
			result.setData(data);
			result.setStatus("n");
			break;
		default:
			result.setCode(5000);
			result.setData(data);
			result.setInfo("自动结果，系统未定义结果");
			result.setMessage("自动结果，系统未定义结果");
			result.setStatus("n");
		   break;
		}
		
		
		return result;		
	}
}
